<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>任务管理</title>
    <link rel="stylesheet" href="<?php echo DC_STATICS;?>/libs/layui/2.13.0/css/layui.css">
    <link rel="stylesheet" href="<?php echo DC_STATICS;?>/devc/css/main.css">
</head>
<body>
    <div class="page-container">
        <div class="page-header">
            <h2 class="page-title">任务管理</h2>
        </div>
        
        <!-- 工具栏 -->
        <div class="table-toolbar">
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-sm" id="add-task"><i class="layui-icon">&#xe654;</i> 新增任务</button>
            </div>
            
            <!-- 筛选条件 -->
            <div class="layui-form layui-inline">
                <div class="layui-input-inline" style="width: 150px;">
                    <select name="status" lay-filter="status">
                        <option value="">全部状态</option>
                        <option value="待处理">待处理</option>
                        <option value="进行中">进行中</option>
                        <option value="已完成">已完成</option>
                        <option value="已取消">已取消</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <input type="text" name="search" placeholder="搜索任务名称" autocomplete="off" class="layui-input">
                </div>
                <button class="layui-btn layui-btn-primary layui-btn-sm" id="search-btn"><i class="layui-icon">&#xe615;</i> 搜索</button>
            </div>
        </div>
        
        <!-- 任务列表 -->
        <table id="task-table" lay-filter="task-table"></table>
        
        <!-- 表格操作按钮模板 -->
        <script type="text/html" id="table-operation">
            <a class="layui-btn layui-btn-sm" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
        </script>
        
        <!-- 状态模板 -->
        <script type="text/html" id="statusTpl">
            {{#  if(d.task_status === '0'){ }}
            <span class="layui-badge layui-bg-orange">待处理</span>
            {{#  } else if(d.task_status === '1'){ }}
            <span class="layui-badge layui-bg-blue">进行中</span>
            {{#  } else if(d.task_status === '2'){ }}
            <span class="layui-badge layui-bg-green">已完成</span>
            {{#  } }}
        </script>
        
        <!-- 类型模板 -->
        <script type="text/html" id="typeTpl">
            {{#  if(d.task_type === '0'){ }}
            <span class="layui-badge layui-bg-blue">研发任务</span>
            {{#  } else if(d.task_type === '1'){ }}
            <span class="layui-badge layui-bg-red">Bug修改</span>
            {{#  } }}
        </script>
        
        <!-- 优先级模板 -->
        <script type="text/html" id="priorityTpl">
            {{#  if(d.task_priority === '0'){ }}
            <span class="layui-badge layui-bg-blue">一般</span>
            {{#  } else if(d.task_priority === '1'){ }}
            <span class="layui-badge layui-bg-red">紧急</span>
            {{#  } }}
        </script>
    </div>
    
    <!-- 新增/编辑任务表单 -->
    <div id="task-form" style="display: none; padding: 20px;">
        <form class="layui-form" lay-filter="task-form">
            <div class="layui-form-item">
                <label class="layui-form-label">任务名称</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name" required lay-verify="required" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属应用</label>
                <div class="layui-input-block">
                    <select name="application_id" lay-verify="required" lay-filter="form-application" id="form-application-select">
                        <option value="">请选择应用</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属版本</label>
                <div class="layui-input-block">
                    <select name="version_id" lay-verify="version_id" lay-filter="form-version" id="form-version-select">
                        <option value="">请选择版本</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属功能</label>
                <div class="layui-input-block">
                    <select name="feature_id" lay-verify="required" id="form-feature-select">
                        <option value="">请选择功能</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea name="task_desc" placeholder="请输入任务描述" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">任务类型</label>
                <div class="layui-input-block">
                    <select name="task_type" lay-verify="required">
                        <option value="0">研发任务</option>
                        <option value="1">Bug修改</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">起始时间</label>
                <div class="layui-input-block">
                    <input type="text" id="start_end_time" placeholder="请选择任务起始时间" autocomplete="off" class="layui-input">
                    <input type="hidden" name="start_time" id="start_time" />
                    <input type="hidden" name="end_time" id="end_time" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">优先级</label>
                <div class="layui-input-block">
                    <select name="task_priority" lay-verify="required">
                        <option value="0">一般</option>
                        <option value="1">紧急</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select name="task_status" lay-verify="required">
                        <option value="0">待开始</option>
                        <option value="1">进行中</option>
                        <option value="2">已完成</option>
                    </select>
                </div>
            </div>
            <!-- 表单按钮已移除，使用弹窗底部按钮 -->
            <input type="hidden" name="id">
        </form>
    </div>
    <script src="<?php echo DC_STATICS;?>/libs/layui/2.13.0/layui.js"></script>
    <script src="<?php echo DC_STATICS;?>/devc/js/tasks.js?v=0.1.1"></script>
    <script>
    layui.use(['table', 'form', 'layer', 'tasks'], function(){
        var tasks = layui.tasks;
        tasks.init();
    });
    </script>
</body>
</html>